<?php
class Contact extends Controller {
	
	function index() {
		

		$this->load->view('contact_form');
		
	}
	
	function submit() {

        $this->load->library("email");

        //configuracion para gmail
        $configGmail = array(
            'protocol' => 'smtp',
            'smtp_host' => 'localhost',
            'smtp_port' => 25,
            'smtp_user' => '',
            'smtp_pass' => '',
            'mailtype' => 'html',
            'charset' => 'utf-8',
            'newline' => "\r\n"
        );

        //cargamos la configuración para enviar con gmail
        $this->email->initialize($configGmail);

        $email = $this->input->post('email');
        $message = $this->input->post('message');
        $this->email->from($email);
        $this->email->to("contact@manahorno.com");
        $this->email->subject('desde contact form');
        $this->email->message($message);
        $this->email->send();
        //con esto podemos ver el resultado
        //var_dump($this->email->print_debugger());

		if ($this->input->post('ajax')) {

			$this->load->view("contact_submitted");
		} else {

            $this->load->view('contact_form');
		}
	}
	
}
